﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iLangl.Model;
using System.Data;
using iLangl.LanguageWire.DAL.iLanglDAL;
using iLangl.LanguageWire.LWIntegration;

namespace iLangl.LanguageWire.Managers
{
	public class ContactManager : BaseManager
	{
		#region Singelton Pattern
		private ContactManager()
		{
		}

		private static ContactManager instance;
		private static object mutex = new object();
		/// <summary>
		/// The instance of the CompanyManager.
		/// </summary>
		public static ContactManager Instance
		{
			get
			{
				if (instance == null)
				{
					lock (mutex)
					{
						if (instance == null)
						{
							instance = new ContactManager();
						}
					}
				}
				return instance;
			}
		}
		#endregion

		public Contact GetResponsiblePerson(Int32 JobId)
		{
			Contact contact = DALFacadeLWAPI.ContactDAL.GetResponsiblePerson(JobId);

			return contact;
		}


		public void CreateContact(Contact contact)
		{
			createContact(contact, false);
		}



		internal void CreatePrimaryContact(Contact contact)
		{
			createContact(contact, true);
		}

		private void createContact(Contact contact, Boolean isPrimary)
		{
			DALFacadeLWAPI.ContactDAL.CreateContact(contact, isPrimary);
		}
	}
}
